#include "Parent.h"

Parent::Parent( Printer &prt, Bank &bank, 
				unsigned int numStudents, unsigned int parentalDelay ) :
myPrinter(prt), myBank(bank)
{
	myNumStudents = numStudents;
	myParentalDelay = parentalDelay;
}

Parent::~Parent(){
    
}

void Parent::main()
{
    myPrinter.print(Printer::Parent, 'S');
    for(;;)
    {
        _Accept(~Parent) 
        {
            break;
        }else{
            yield(myParentalDelay);
            unsigned int money = Global::prng() % 3 + 1;
            unsigned int id = Global::prng() % myNumStudents;
            myPrinter.print(Printer::Parent, 'D', id, money);
            myBank.deposit(id, money);  
        }      
    }
    myPrinter.print(Printer::Parent, 'F');
}
